package top.aiprogram.user.controller;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.ui.ModelMap;
import org.springframework.web.bind.annotation.RequestMapping;
import top.aiprogram.user.entity.Student;
import top.aiprogram.user.service.StudentService;


import javax.servlet.http.HttpServletRequest;

/**
 * Created by HP on 2018/10/10.
 */
//完整的项目整合以及框架.测试全部都正常
@Controller
@RequestMapping("user")
public class StudentController {
  @Autowired
    private StudentService studentService;
    @RequestMapping("test")
    public String demo2(ModelMap modelMap, HttpServletRequest httpServletRequest){
        return "test";
    }
    @RequestMapping("demo1")
    public String demo1(ModelMap modelMap, HttpServletRequest httpServletRequest){
        String id = httpServletRequest.getParameter("id");
        String name = httpServletRequest.getParameter("name");
        Student student=new Student(id,name);
        int i = studentService.creatStudent(student);
        modelMap.addAttribute("num",i);
        System.out.println(i);
        return "demo";
    }

}
